package com.cnap.controller;

import com.cnap.CnapApplicationTests;
import com.cnap.model.indicator.IndicatorVO;
import com.cnap.model.schedule.UpdateMicroServiceStatusParam;
import com.cnap.model.schedule.UpdateMicroserviceClusterParam;
import com.cnap.model.stage.UpdateStageParam;
import com.cnap.service.DistributeDeployService;
import com.cnap.service.IndicatorService;
import com.cnap.service.MicroSvcService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;

/**
 * <类文件描述>
 *
 * @author xc
 **/
class SystemControllerTest extends CnapApplicationTests {

    @Autowired
    private SystemController systemController;
    @MockBean
    private MicroSvcService microSvcService;
    @MockBean
    private IndicatorService indicatorService;
    @MockBean
    private DistributeDeployService distributeDeployService;

    @Test
    void updateMicroServiceStatus() {
        UpdateMicroServiceStatusParam param = new UpdateMicroServiceStatusParam();
        Mockito.when(microSvcService.updateMicroServiceStatus(param)).thenReturn(true);

        Assertions.assertDoesNotThrow(() -> {
            systemController.updateMicroServiceStatus(param);
        });
    }

    @Test
    void getIndicatorByServiceId() {
        Mockito.when(indicatorService.getAllIndicatorByServiceId("svcId")).thenReturn(new IndicatorVO());

        Assertions.assertDoesNotThrow(()->{
            systemController.getIndicatorByServiceId("svcId");
        });
    }

    @Test
    void updateClusterInfo() {
        UpdateMicroserviceClusterParam param = new UpdateMicroserviceClusterParam();
        Mockito.when(microSvcService.updateClusterInfo(param)).thenReturn(true);

        Assertions.assertDoesNotThrow(() -> {
            systemController.updateClusterInfo(param);
        });
    }

    @Test
    void updateStageStatus() {
        UpdateStageParam param = new UpdateStageParam();
        Mockito.when(distributeDeployService.updateStage(param)).thenReturn(true);

        Assertions.assertDoesNotThrow(() -> {
            systemController.updateStageStatus(param);
        });
    }
}